package org.xiao.web.groovyweb.config

import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.PropertySource
import org.springframework.core.env.Environment
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer

@Configuration
@PropertySource(value = "classpath:res.properties")
class ExtResConfig implements WebMvcConfigurer{
    @Autowired
    Environment environment

    void addResourceHandlers(ResourceHandlerRegistry registry){
        def path=environment.getProperty("res.path")
        registry.addResourceHandler("/res/**")
                .addResourceLocations("file:${path}")
    }
}
